home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / MacSNMP / SNMP Agents Dev Kit / Tools / LinkSharedLibrary < prev    next >
Encoding:
Text File  |  1994-11-21  |  3.8 KB  |  121 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        LinkSharedLibrary
  3. #
  4. #    Contains:    Script to link a shared library
  5. #
  6. #    Copyright:    © 1992-1993 by Apple Computer, Inc., all rights reserved.
  7. #
  8. #
  9.  
  10. Set OutFile        ""
  11. Set InObj        ""
  12. Set SymFile        ""
  13. Set Error        0
  14. Set NoMerge        0
  15. Set model        "-model far"
  16. If "{TempFolder}" != ""
  17.     Set Scratch "{TempFolder}"
  18. Else
  19.     Set Scratch "{CPlusScratch}"
  20. End
  21. Set MapFile        "{Scratch}SharedLibTemp.Map" 
  22. Set UsrMap        0
  23. LOOP
  24.     If "{1}" == "" || "{1}" !~ /-≈/
  25.         Break;
  26.     Else If "{1}" =~ /-link/
  27.         Shift; Break;
  28.     Else If "{1}" =~ /-near/
  29.         Set model "-model near"
  30.     Else If "{1}" =~ /-far/
  31.         Set model "-model far"
  32.     Else If "{1}" =~ /-noMerge/
  33.         Set NoMerge 1
  34.     Else If "{1}" =~ /-map/
  35.         Set MapFile "{2}"; Shift 2; Set UsrMap 1; Continue
  36.     Else If "{1}" =~ /-symfile/
  37.         Set SymFile "{2}"; Shift 2; Continue
  38.     Else If "{1}" =~ /-obj/
  39.         Set InObj "{2}"; Shift 2; Continue
  40.     Else If "{1}" =~ /-lib/
  41.         Set OutFile "{2}";    Shift 2; Continue
  42.     Else
  43.         Set Error 1
  44.         Break;
  45.     End
  46.     Shift
  47. End
  48. If "{InObj}" == "" || "{OutFile}" == ""
  49.     Set Error 1
  50. End
  51. If {Error}
  52.         Echo "Usage: LinkSharedLibrary -lib <OutputLibrary>"
  53.         Echo "       -obj <ObjectRootName>"
  54.         Echo "       -map <MapFileName>"
  55.         Echo "       -noMerge"
  56.         Echo "        -link <Parameters for the link>"
  57.         Echo ""
  58.         Echo "Must be used after using BuildSharedLibrary"
  59.         Echo ""
  60.         Echo "    The name after the -obj flag describes the base name for all of"
  61.         Echo "    the files resulting from invoking this tool.  The following"
  62.         Echo "    are added to the base name you supply:"
  63.         Echo "       .lib.o - The actual shared library object file"
  64.         Echo "       .libr.r - Resource to rez with the shared library resource"
  65.         Echo "       .deps - File used to create the dependency ('libi') resource"
  66.         Echo "       .init.o - Initialization code for the library\n"
  67.         Echo "       .ia.o - Initialization code for the library\n"
  68.         Echo "    This should be the same name you passed to the BuildSharedLibrary"
  69.         Echo "    Script"
  70.         Echo ""
  71.         Echo "    Everything after -link will be passed to the linker directly."
  72.         Echo "    The list of libraries to link with must be last"
  73.         Echo "    or after the -link switch."
  74.         Echo "    The link automatically merges segments Main, STDCLIB, STDIO,"
  75.         Echo "    CSANELib, SANELIB, %Complex, SADEV, and INTENV unless you"
  76.         Echo "    specify the NoMerge flag"
  77.         Exit 10
  78. End
  79. If {Progress}
  80.     Echo "∂t∂tCreating shared Library file ∂"{OutFile}∂""
  81. End
  82.  
  83. If {NoMerge} == 0
  84.     Set SegMerge "-sn STDIO=Main -sn STDCLIB=Main -sn CSANELib=Main -sn %Complex=Main -sn SADEV=Main -sn INTENV=Main -sn SANELIB=Main"
  85. Else
  86.     Set SegMerge ""
  87. End
  88. Duplicate -y "{InObj}.libr.r" "{Scratch}SharedLibTemp.temp.r"
  89.  
  90. Delete -i "{Scratch}SharedLibTemp.RSRC.SYM"
  91. If "`Exists -f "{InObj}.deps"`"
  92.     Set HaveDeps 1
  93.     Link {model} -d -t rsrc -c RSED ∂
  94.         -sg %A5Init=A5Init -ra %A5Init=resLocked -m DynamicCodeEntry -o "{Scratch}SharedLibTemp.RSRC" ∂
  95.         "{InObj}.init.o" "{InObj}.ia.o" "{InObj}.lib.o" -map >"{MapFile}" ∂
  96.         {SegMerge} {"Parameters"}
  97.     CreateLibraryLoadRsrc -map "{MapFile}" -out "{Scratch}SharedLibTemp.temp.r" ∂
  98.         -resid SLMID -a -readx "{InObj}.deps"
  99. Else
  100.     Set HaveDeps 0
  101.     Link {model} -d -t rsrc -c RSED ∂
  102.         -sg %A5Init=A5Init -ra %A5Init=resLocked -m DynamicCodeEntry -o "{Scratch}SharedLibTemp.RSRC" ∂
  103.         "{InObj}.init.o" "{InObj}.ia.o" "{InObj}.lib.o" ∂
  104.         {SegMerge} {"Parameters"}
  105. End
  106. If "`Exists -f "{Scratch}SharedLibTemp.RSRC.SYM"`"
  107.     Duplicate -y "{Scratch}SharedLibTemp.RSRC.SYM" "{SymFile}"
  108.     Delete -i "{Scratch}SharedLibTemp.RSRC.SYM"
  109. End
  110.  
  111. Echo "Include ∂"{Scratch}SharedLibTemp.RSRC∂" 'CODE' as SLMType;" >> "{Scratch}SharedLibTemp.temp.r"
  112. Echo "Delete SLMType (∂"32-bit bootstrap∂");" >> "{Scratch}SharedLibTemp.temp.r"
  113.  
  114. Delete -i "{OutFile}" ∑∑ Dev:Null
  115. Rez -a -t libr -c OMGR ∂
  116.     -o "{OutFile}" "{Scratch}SharedLibTemp.temp.r"
  117. SetFile -a ib "{OutFile}"
  118. delete -i "{Scratch}SharedLibTemp.temp.r" "{Scratch}SharedLibTemp.RSRC"
  119. If {HaveDeps} != 0 AND {UsrMap} == 0
  120.     Delete -i "{MapFile}"
  121. End